<template>
    <setting-item-box name="名称" :alone="true">
        <a-input 
            v-model:value="chartConfig.title"  
            size="small" 
            placeholder="请输入图表名称" 
            show-count 
            :maxlength="20" 
            allowClear
            @change="handleChange"
        />
    </setting-item-box>
</template>

<script setup lang="ts">
import settingItemBox from '@/components/chart/settingItemBox/index.vue';
import { showMsg } from '@/utils';
import type { ConfigType } from '@/views/dataview/packages/type';
import { computed, ref } from 'vue';

const props = withDefaults(defineProps<{
    chartConfig:ConfigType
}>(),{})

let defaultValue = computed(()=>props.chartConfig.title)
const handleChange = (e:InputEvent)=>{
    if(props.chartConfig.title.length === 0){
        props.chartConfig.title = defaultValue.value
        showMsg("名称不能为空",'warning')
    }
}
</script>

<style lang='scss' scoped></style>